from flask import Flask, request

app = Flask(__name__)

#url: http[80]/https[443]://www.qq.com:443/path
#url与视图：准确的来说是path与视图
@app.route('/')
def hello_world():  # put application's code here
    return 'Hello World!'

@app.route("/profile")
def profile():  # put application's code here
    return "我是个人中心！"

@app.route("/blog/list")
def blog_list():  # put application's code here
    return "我是博客列表！"

#带参数的url:将参数固定到了path中
@app.route("/blog/<blog_id>")
def blog_detail(blog_id):  # put application's code here
    return "您访问的博客是：%s" % blog_id

# /book/list: 会给我返回第一页的数据
# /book/list?page=2: 获取第二页的数据
@app.route('/book/list')
def book_list():
    # arguments: 参数
    # request.args:类字典类型
    page = request.args.get("page", default=2, type=int)
    return f"您获取的是第{page}的图书列表！"


if __name__ == '__main__':
    app.run()
